package school;
import java.util.ArrayList;
import java.util.List;

public class Student {
    private String studentId;
    private String studentName;
    private String gender;
    private List<String> courseIds = new ArrayList<>(); // 所选课程编号列表

    public Student(String studentId, String studentName, String gender) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.gender = gender;
    }

    // 选课方法
    public boolean selectCourse(String courseId) {
        if (!courseIds.contains(courseId)) {
            courseIds.add(courseId);
            return true;
        }
        return false;
    }

    // 退课方法
    public boolean dropCourse(String courseId) {
        return courseIds.remove(courseId);
    }

    // Getter 和 Setter 方法
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public List<String> getCourseIds() {
        return courseIds;
    }

    @Override
    public String toString() {
        return "学生编号: " + studentId + ", 学生姓名: " + studentName + ", 性别: " + gender + ", 所选课程编号: " + courseIds;
    }
}